﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace MMFWriterB
{
    class Program
    {
        static void Main(string[] args)
        {
            using (MemoryMappedFile mmf = MemoryMappedFile.OpenExisting("testmap"))
            {
                Mutex sigal = Mutex.OpenExisting("testmapmutex");
                sigal.WaitOne();
                using (var stream = mmf.CreateViewStream(2,0))
                {
                    StreamWriter writer = new StreamWriter(stream);
                    writer.Write(1);
                }
                sigal.ReleaseMutex();
            }
        }
    }
}
